package isssr.control.src;

import isssr.entity.src.Perspective;
import isssr.entity.src.UserContext;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;


@ManagedBean(name="userAdministrationControl")
@SessionScoped

public class UserAdministrationControl implements Serializable {

	private static final long serialVersionUID 		= -7155374195330103296L;
	private static final String OWNER_VIEW_URL 		= "change-user-perspective-owner";
	private static final String SUPER_VIEW_URL 		= "change-user-perspective-super";
	private static final String ENACTOR_VIEW_URL 	= "change-user-perspective-enactor";
	
	
	@ManagedProperty(value="#{userContext}")
	private UserContext currentContext;
	
	
	public UserAdministrationControl(){}


	public void setCurrentContext(UserContext current_context) {
		this.currentContext = current_context;
	}
	
	
	public String changeUserPerspective(Perspective viewType) {
		String retUrl = null;
		
		switch (viewType) {
		case OWNER_VIEW:
			retUrl = OWNER_VIEW_URL;
			this.currentContext.setView(Perspective.OWNER_VIEW);
			break;
		case SUPER_OWNER_VIEW:
			retUrl = SUPER_VIEW_URL;
			this.currentContext.setView(Perspective.SUPER_OWNER_VIEW);
		case ENACTOR_VIEW:
			retUrl = ENACTOR_VIEW_URL;
			this.currentContext.setView(Perspective.ENACTOR_VIEW);
		default:
			break;
		}
		
		return retUrl;
	}
	
	
	public void editUserAccount() {
		
	}
	
	
}
